﻿using System; 
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using WebSocketSharp; 

namespace ClassLibrary1
{
     public class Program
     {
          public  static void Main(string[] args)
          {
               
               
              
               using (var ws = new WebSocket("wss://localhost:5001/ws"))
               {
                     
                    
                    ws.OnOpen += (sender, eventArgs) =>
                    {
                         Console.WriteLine("open");
                    };
                    ws.OnMessage += (sender, eventArgs) =>
                    {
                         Console.WriteLine(eventArgs.Data);
                    };
                    ws.OnClose += (sender, eventArgs) =>
                    {
                         
                         Console.WriteLine($"close :{eventArgs.Reason}--- {eventArgs.Code}");
                    };
                    ws.OnError += (sender, eventArgs) =>
                    {
               
                         Console.WriteLine("error:"+eventArgs.Exception);
                    };
                    
                    ws.ConnectAsync();
                    while (true)
                    {
                         ws.SendAsync(Guid.NewGuid().ToString(), x =>
                         {
                              Task.Delay(1000);
                         });
                    }
                    Console.ReadLine();
               }


          }
     }
  
}